<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<table border="1px">
  <caption>个人信息</caption>
  <tr>
    <td>照片</td><td id="pic_td"></td>
  </tr>
  <tr>
    <td>姓名</td><td id="name_td"></td>
  </tr>
  <tr>
    <td>年龄</td><td id="age_td"></td>
  </tr>
  <tr>
    <td>好友</td><td id="friends_td"></td>
  </tr>
</table>
<button onclick="load()">加载数据</button>
<script>
  function load() {
    /*模拟从服务器请求到的数据*/
    let p = {
      name:"坤坤",age:18,url:"../2.png",friends:["小花","小芳","小海"]}
    let nameTd = document.querySelector("#name_td");
    let ageTd = document.querySelector("#age_td");
    /*要访问对象数据直接对象点属性名就OK*/
    nameTd.innerText = p.name;
    ageTd.innerText = p.age;
    /*设置显示图片*/
    let picTd = document.querySelector("#pic_td");
    let img = document.createElement("img");
    img.src = p.url;
    img.width = 200;
    picTd.append(img);
    /*显示好友*/
    let friendsTd = document.querySelector("#friends_td");
    let ul = document.createElement("ul");
    /*遍历friends数组*/
    for (let friend of p.friends) {
      /*通过for of循环来创建li 并且依次获取对应属性值*/
      let li = document.createElement("li");
      li.innerText = friend;
      ul.append(li);
    }
    friendsTd.append(ul);
  }
</script>
</body>
</html>